class User < ActiveRecord::Base
  acts_as_authentic
  has_many :entries, :as => :content_generator
  has_many :comments, :as => :content_generator

  def user_dir
    return "users/#{self.username}"
  end

	def photoblog_dir
		return "#{self.user_dir}/photoblog"
	end

	def setup_user_dir
		FileUtils.mkdir_p("public/#{self.photoblog_dir}")
	end

	def photoblog_sourcedirs
		d = Dir.new("public/#{self.photoblog_dir}")
		sourcedirs = Array.new

		while filename = d.read do
			if filename != '..' && filename != '.'
				sourcedirs << "#{self.photoblog_dir}/#{filename}"
			end
		end

		return sourcedirs
	end
end
